﻿using System;

using Xamarin.Forms;
using Xamarin.Forms.Xaml;
using Xarmarin.GoldFinger.Engine.Core;
using Xarmarin.GoldFinger.Engine.Rand;
using Xarmarin.GoldFinger.Models.AutoModels;
using Xarmarin.GoldFinger.Services;

namespace Xarmarin.GoldFinger.Views.KzSystem
{
    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class CreatedSubjectPage : ContentPage
    {
        public CreatedSubjectPage()
        {
            InitializeComponent();
            Title = "创建";

            RealName.Text = Engine.Rand.RandName.Name;

        }
        private void Button_Clicked(object sender, EventArgs e)
        {

            var model = new Auto_Subject()
            {
                RealName = RealName.Text,
                IcoFace = "f_jsmile.png",
                State = (long)SimpleState.Default,
                StateStr = SimpleState.Default.GetDescription(),
                SmallState = (long)SmallState.Inferior,
                SmallStateStr = SmallState.Inferior.GetDescription(),
                SectName = "无门散修",
                SectPosition = (long)SectPosition.UnKnow,
                SectPositionStr = SectPosition.UnKnow.GetDescription(),
                Account = "A" + Guid.NewGuid().ToString(),
                //随机年纪
                Age = RandCore.GetRandValue(10, 20),
                //寿命
                LifeYear = 80,
                //初始气运
                Lucy = RandCore.GetRandValue(1, 10),
                //因果
                Karma = 0,
            };
            //初始灵根
            model.ManaRoot = (long)model.Lucy * (RandCore.GetRandValue());
            //悟性
            model.Savvy = (long)model.Lucy * (RandCore.GetRandValue());
            //体魄
            model.Physique = (long)model.Lucy * (RandCore.GetRandValue());
            //神魂
            model.Mind = (long)model.Lucy * (RandCore.GetRandValue());
            model.MixGetMana = RandCore.GetRandValue();
            model.MaxGetMana = RandCore.GetRandValue((int)model.MixGetMana,(int)(model.MixGetMana +(model.Lucy * model.ManaRoot)/100+RandCore.GetRandValue(10,99)));
            SubjectDataStore.AddRandSubject(model);
            Application.Current.MainPage =
            new NavigationPage(SinglePageManager.MainPage);
            //Navigation.PushAsync(SinglePageManager.MainPage);
        }

        private void Button_Clicked_Rand(object sender, EventArgs e)
        {
            RealName.Text = Engine.Rand.RandName.Name;
        }
    }
}